# -*- coding: utf-8 -*-

# 装饰器本质上python函数，它可以让其他函数在没有任何变动的情况下增加额外功能，装饰器的返回值也是一个函数对象。

def star(func):
    def inner(*args, **kwargs):
        print("*" * 30)
        func(*args, **kwargs)
        print("*" * 30)
    return inner                            # 不需要加()


def percent(func):
    def inner(*args, **kwargs):
        print("%" * 30)
        func(*args, **kwargs)
        print("%" * 30)
    return inner

# 以上语法
# @star
# @percent
# def printer(msg):
#     print(msg)
# printer("Hello")

# 相当于以下
def printer(msg):
    print(msg)
printer = star(percent(printer))
printer("Hello")
